﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ASP.NET_MVC_Static_Test.Common
{
    public static class IpControlHelper
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        public static long IpVisitNumber(string ip)
        {
            var redisHelper = new RedisHelper();
            long visitNum = 0;
            if (!redisHelper.KeyExists(ip))
            {
                visitNum = redisHelper.Increment(ip);
                redisHelper.KeyExpire(ip, new TimeSpan(0, 0, 1, 0));
            }
            else
            {
                visitNum = redisHelper.Increment(ip);
            }

            return visitNum;
        }

    }
}